package route

import (
	"app/common"
	"app/controller"
	"github.com/gin-gonic/gin"
)

var Router = gin.Default()

func Routes() *gin.Engine {
	// 添加 RequestId 中间件（必须在其他中间件之前）
	Router.Use(common.RequestIdMiddleware())
	// 添加panic恢复中间件
	Router.Use(common.RecoveryHandler())
	// 添加错误处理中间件
	Router.Use(common.ErrorHandler())

	Router.Use(common.ServiceContextMiddleware())

	goGroup := Router.Group("go", common.After())
	{
		goGroup.GET("/ping", func(c *gin.Context) {
			cnt := controller.NewTestEqLogLogic(c)
			cnt.PingHandler()
		})
	}

	return Router
}
